|
|
|
|
|
|
|
You can then use the subroutines presented earlier that display parametric curves to display Hermite curves. Example program Hermite, shown in Figure 11.14, does just that. Enter the values of Vx1, Vy1, Vx2, and Vy2 in text boxes. Use the mouse to drag the curve's endpoints to new positions. When you have made the changes you want, click the Go button to have the program display the curve. |
|
|
|
|
|
|
|
|
If you check the Show Control Points check box, the program also draws the endpoints and the tangent vectors. The vectors are scaled by a factor of 1/5 because interesting values for the vectors tend to be fairly large. |
|
|
|
|
|
|
|
|
Hermite Blending Functions |
|
|
|
|
|
|
|
|
If you take the equations for ax, bx, and so forth, and plug them into the equation for the finished curve X(t) = ax * t3 + bx * t2 + cx * t + dx, you get: |
|
|
|
 |
|
|
|
|
X(t) = (Vx2 + Vx1 - 2 * Ex2 + 2 * Ex1) * t3 +
(3 * Ex2 - 2 * Vx1 - 3 * Ex1 - Vx2 * t2 +
Vx1 * t + Ex1 = Ex1 * (2 * t3 - 3 * t2 + 1) +
Ex2 * (-2 * t3 + 3 * t2) +
Vx1 * (t3 - 2 * t2 + t) +
Vx2 * (t3 - t2) |
|
|
|
|
|
|
|
|
The functions multiplying the Ex1, Ex2, Vx1, and Vx2 terms are called blending functions. They produce values for the points on the curve by blending together different amounts of Ex1, Ex2, Vx1, and Vx2 as t varies from 0 to 1. |
|
|
|
|
|
|
|
|
Figure 11.14
Program Hermite displaying a Hermite curve. |
|
|
|
|
|